package net.xuwu.marry.service.init.action;

import java.util.HashMap;
import java.util.Map;
import net.sf.json.JSONObject;
import net.xuwu.marry.common.constant.GlobinConstant;
import net.xuwu.marry.common.struts.MarryStrutsAction;

public class LoginAction extends MarryStrutsAction {

	
	private String result = "";
	
	
	public LoginAction() {
		System.out.println("===================================");
	}

	/**
	 * �û�ע��
	 * @return
	 */
	public String reg(){
		
		try {
			//接收前台json
			JSONObject jsonData = JSONObject.fromObject(super.getRequest().getAttribute(GlobinConstant.RECEIVE_JSON_DATA));
			//json转化成bean
	//		UserBasicBean ubb = (UserBasicBean)JSONObject.toBean(json, UserBasicBean.class);
			
			Map<String,Object> reqMap = new HashMap<String, Object>();
			reqMap.put("status",GlobinConstant.BUSY_INFO);
			JSONObject json = JSONObject.fromObject(reqMap);
			result = json.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "reg";
	}
	
	/**
	 * 登录
	 * @return
	 */
	public String login(){
		try {
			JSONObject jsonData = JSONObject.fromObject(super.getRequest().getAttribute(GlobinConstant.RECEIVE_JSON_DATA));
			Map<String,Object> reqMap = new HashMap<String, Object>();
			reqMap.put("status",GlobinConstant.BUSY_INFO);
			super.getSession().put(GlobinConstant.SESSION_KEY, "admin");
			JSONObject json = JSONObject.fromObject(reqMap);
			result = json.toString();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "login";
	}
	
	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
	
	
}
